import { Route, Switch, Link, Redirect, useHistory } from 'react-router-dom';
import React, { use } from 'react'
import Home3 from './Home3'
import Login3 from './Login3'

const Home = (props) => {
    if (localStorage.getItem('isLogin') !== 'true') {
        {console.log('请先登录');}
        <h2>登录页面</h2>
        props.history.replace('/login')
        return <Login3 />

    } else if (localStorage.getItem('isLogin') === 'true') {
        {console.log('您已登陆，可继续浏览首页');}
        <h2>首页页面</h2>
        return <Home3 />
        
    }
}
export const Login = (props) => {

    if (localStorage.getItem('isLogin') === 'true') {
        {console.log('您已登录，将返回首页')}
        <h2>首页页面</h2>
        props.history.replace('/')
        return <Home3 />
    } else {
        {console.log('请登录')}
        <h2>登录页面</h2>
        return <Login3 />
    }

}

const Content3 = () => {
    return (
        <div className='conent-wrap'>
            <Switch>
                <Route exact path='/' component={Home} />
                <Route path='/login' component={Login} />
            </Switch>
        </div>
    )
}

export default Content3
